#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
	pid_t id=fork();
	if(id==0)//子进程
	{
		char* const argv[]={
			(char*)"ls",
			(char*)"-l",
			(char*)"-a",
			(char*)"--color",
			nullptr
		};
	
//		execlp("ls","ls","-la","--color",nullptr);

		execv("/usr/bin/ls",argv);
		exit(1); 
	}

	pid_t rid=waitpid(id,nullptr,0);
	if(rid>0)
	{
		printf("等待子进程成功！！\n");	
	}


	//printf("I am exxcl,my pid is:%d\n",getpid());
	//int rid=execl("/bin/ls","ls","-l","-a","--color",nullptr);
	//int rid=execl("/usr/bin/top","top",nullptr);	
	//int rid=execl("/usr/bin","python3","test1.py",nullptr);
	//printf("return value is:%d\n",rid);



	return 0;
}
